import request from '@/utils/request'

// 查询单据明细列表（以批次号和药品名称为主）
export function listBillsDetail(query) {
  return request({
    url: '/wareHouse/list/detailList',
    method: 'get',
    params: query
  })
}

// 查询单据主表详细
export function getList(BillsID) {
  return request({
    url: '/wareHouse/list/' + BillsID,
    method: 'get'
  })
}


// 删除单据主表（软删除，将状态改为3）
export function delList(BillsIDs) {
  return request({
    url: '/wareHouse/list/softDelete',
    method: 'put',
    data: BillsIDs
  })
}


// 上传单据到易联云码平台
export function uploadBills(billsID, institutionData) {
  return request({
    url: '/wareHouse/list/upload/' + billsID,
    method: 'post',
    data: institutionData
  })
}

// 获取首页统计数据
export function getDashboardStatistics() {
  return request({
    url: '/wareHouse/list/dashboard/statistics',
    method: 'get'
  })
}

// 根据父级码获取子码
export function getChildCodesByParentCode(parentCode) {
  return request({
    url: '/wareHouse/list/qrcode/children/' + encodeURIComponent(parentCode),
    method: 'get'
  })
}

// 根据单据ID和药品ID获取层级结构的二维码信息
export function getQrCodeHierarchyByBillsIDAndDrugID(billsID,drugBatchNo, drugID) {
  return request({
    url: '/wareHouse/list/qrcode/hierarchy/' + billsID + '/' + drugID+ '/' + drugBatchNo,
    method: 'get'
  })
}

// 获取单据明细列表（用于批次号维护）
export function getBillsDetailList(billsID) {
  return request({
    url: '/wareHouse/list/detail/' + billsID,
    method: 'get'
  })
}

// 更新明细批次号
export function updateDetailBatchNumber(data) {
  return request({
    url: '/wareHouse/list/detail/batchNumber',
    method: 'put',
    data: data
  })
}

